package bytebuddys;

import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;

import java.lang.reflect.Method;

public class TypeVariableSourceTest {

    public <T extends Food> T makeFood(T food) {

        return food;
    }

    public Object makeSauce() {

        class Sauce {
            public void print() {
            }
        }

        return new Sauce();
    }

    // 食物
    public static class Food {

    }


    public static void main(String[] args) throws Exception {


        Method makeFood = TypeVariableSourceTest.class.getDeclaredMethod("makeFood", Food.class);


        MethodDescription.ForLoadedMethod makeFoodBD = new MethodDescription.ForLoadedMethod(makeFood);
        System.out.println("Inferrce 可否动态修改: " + makeFoodBD.isInferrable());
        System.out.println("isGenerified() 是否或者包含泛型: " + makeFoodBD.isGenerified());
        System.out.println("Enclosing 外围的包裹类或者方法: " + makeFoodBD.getEnclosingSource().toString());
        System.out.println("getTypeVariables() 获取泛型: " + makeFoodBD.getTypeVariables().toString());
        System.out.println("Enclosing 外围的包裹类或者方法: " + makeFoodBD.findVariable("T").toString());

        System.out.println(
                 TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(TypeVariableSourceTest.class).getSymbol()
        );







    }

}

